/**
 */
package de.thwildau.tm.moses.thrift.thrift.impl;

import de.thwildau.tm.moses.thrift.thrift.ContainerType;
import de.thwildau.tm.moses.thrift.thrift.ContainerTypeRef;
import de.thwildau.tm.moses.thrift.thrift.ThriftPackage;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Container Type Ref</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.thwildau.tm.moses.thrift.thrift.impl.ContainerTypeRefImpl#getContainerType <em>Container Type</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ContainerTypeRefImpl extends FieldTypeImpl implements ContainerTypeRef
{
  /**
   * The cached value of the '{@link #getContainerType() <em>Container Type</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getContainerType()
   * @generated
   * @ordered
   */
  protected ContainerType containerType;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ContainerTypeRefImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return ThriftPackage.Literals.CONTAINER_TYPE_REF;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ContainerType getContainerType()
  {
    return containerType;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetContainerType(ContainerType newContainerType, NotificationChain msgs)
  {
    ContainerType oldContainerType = containerType;
    containerType = newContainerType;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ThriftPackage.CONTAINER_TYPE_REF__CONTAINER_TYPE, oldContainerType, newContainerType);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setContainerType(ContainerType newContainerType)
  {
    if (newContainerType != containerType)
    {
      NotificationChain msgs = null;
      if (containerType != null)
        msgs = ((InternalEObject)containerType).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ThriftPackage.CONTAINER_TYPE_REF__CONTAINER_TYPE, null, msgs);
      if (newContainerType != null)
        msgs = ((InternalEObject)newContainerType).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ThriftPackage.CONTAINER_TYPE_REF__CONTAINER_TYPE, null, msgs);
      msgs = basicSetContainerType(newContainerType, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, ThriftPackage.CONTAINER_TYPE_REF__CONTAINER_TYPE, newContainerType, newContainerType));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case ThriftPackage.CONTAINER_TYPE_REF__CONTAINER_TYPE:
        return basicSetContainerType(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case ThriftPackage.CONTAINER_TYPE_REF__CONTAINER_TYPE:
        return getContainerType();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case ThriftPackage.CONTAINER_TYPE_REF__CONTAINER_TYPE:
        setContainerType((ContainerType)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case ThriftPackage.CONTAINER_TYPE_REF__CONTAINER_TYPE:
        setContainerType((ContainerType)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case ThriftPackage.CONTAINER_TYPE_REF__CONTAINER_TYPE:
        return containerType != null;
    }
    return super.eIsSet(featureID);
  }

} //ContainerTypeRefImpl
